home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
keyb
/
buf160_6.zip
/
BUF160.ASM
next >
Wrap
Assembly Source File
|
1992-01-29
|
13KB
|
479 lines
title BUF160
page 58,132
; History:1,1
; Wed Oct 23 17:08:32 1991
;
; v1.6a, 2-29-92, Robert M. Ryan
; - Added CLI and STI in installation routine. (hgm)
;
; v1.6, 2-26-92, Robert M. Ryan
; - On conditional assembly of PRIVATESTACK, this program will create it's
; own stack. This was implemented due to problems on some older PCs.
; - Refine checking of segment boundries, based upon recommendation by
; Harry McGavran (hgm@moki.lanl.gov)
; - Added missing a LES before stuffing data into driver header. (also hgm)
; - Eliminated unnecessary structures and generally cleaned up code.
; - Changed name to BUF160, rather than BUF160_4, BUF160_5, etc.
;
; v1.5 10-23-91 Robert M. Ryan
; - using PUSHA and SHL AX,4 on conditional assembly for 286
; - changed the default buffer status to have TRANSFER enabled, so that
; keys pressed during initialization are preserved.
; - changed case of es and ds to be like the rest of the registers
; - added initialization of BX so Cmd_Init would work
; - slightly modified initialization message
;
; Rob Ryan, Brown University
; Robert_Ryan@brown.edu or 70324.227@CompuServe.Com
;
; v1.4 09-26-88 Toad Hall Tweak
; - Donno WHY all the public mess. Leaving it, tho.
; - Donno why author commented out the buffer transfer code.
; I guess, since we're loading as a driver right at system startup,
; there shouldn't BE anything in the old keyboard buffer.
; Driver works fine with TRANSFER enabled (1), but donno what good it
; does. Therefore leaving the default (and compiled driver) OFF (0).
; - Changed case: constants UPPERCASE, procedures mixed Upper_Lower,
; variables remain lowercase. (Helps to keep my head straight.)
; - Added some comments.
; - Moved Force inline (since only called once)
; - Using string commands in Transfer_Buffer (lodsw, stosw)
; - Just below Transfer_Done, recoded to use AX when stuffing words
; into variables (faster than old code using CX).
;
; David Kirschbaum
; Toad Hall
; kirsch@braggvax.ARPA
;
; 09-21-87 09:31:17 v1.3, fix buf in Force().
; 09-16-87 16:07:46 v1.2, added publics
; 09-16-87 16:01:41 v1.1, comment out buffer transfer code with equate
;
; DJ Delorie
;
;
; To compile:
;
; MICROSOFT ASSEMBLER TURBO ASSEMBLER
; ------------------- ---------------
; masm BUF160; tasm BUF160
; link BUF160; tlink BUF160
; exe2bin BUF160.exe BUF160.sys exe2bin BUF160.exe BUF160.sys
;
; To install, insert the following line in your config.sys:
;
; DEVICE=<path>BUF160.SYS
;
; where "<path>" is the path of the directory containing the device driver
; (e.g., C:\BIN\).
;*****************************************************************************
; Compilation flags
;*****************************************************************************
TRANSFER equ 1 ;Enables keyboard buffer transfer v1.4
; procedure if enabled (1) v1.4
USE286 equ 0 ;Should we use 286 (and later) v1.5
; CPU specific instructions? v1.5
PRIVATESTACK equ 1 ;Use own stack? v1.6
PROGNAME equ 'BUF160'
VERSION equ 'v1.6a, 29 January 1992'
;*****************************************************************************
; General equates
;*****************************************************************************
BUFSIZE equ 160 ;What is the size of the keyboard buffer
STACKSZ equ 100h ;What is the size of the private buffer
SUCCESS equ 0100h
ERROR equ 8100h
BUSY equ 0300h
CR equ 13 ;Carriage Return
LF equ 10 ;Line Feed
TERM equ '$' ;DOS printing terminator character
;*****************************************************************************
; Data structures
;*****************************************************************************
dqq struc
ofs dw ?
segw dw ? ;changed from 'seg' to keep MASM 5.0 happy v1.4
dqq ends
rqq struc ;Request header structure
len db ? ;length of request block (bytes)
unit db ? ;unit #
code db ? ;driver command code
status dw ? ;status return
q1 dd ? ;8 reserved bytes
q2 dd ?
mdesc db ? ;donno
trans dd ?
count dw ?
rqq ends
;*****************************************************************************
; Pointers to BIOS data segment, v1.4
;*****************************************************************************
BIOS_DATA_SEG equ 40H ;MASM had prob using BIOS_DATA in calculations,
; so this typeless constant introduced. v1.6
BIOS_DATA SEGMENT AT BIOS_DATA_SEG
org 1AH
BUFFER_GET dw ? ;org 1ah
BUFFER_PUT dw ? ;org 1ch
org 80H
BUFFER_START dw ? ;org 80h
BUFFER_END dw ? ;org 82h
BIOS_DATA ENDS
;*****************************************************************************
; The actual program
;*****************************************************************************
Cseg segment byte
assume cs:Cseg,ds:Cseg,es:Cseg,ss:Cseg
org 0 ; no offset, it's a .SYS file
start equ $ ; define start=CS:0000
IF USE286 ; v1.5
.286
%OUT Compiling 286 code ...
ELSE
%OUT Compiling generic 8086 code ...
ENDIF
IF PRIVATESTACK
%OUT Using private stack ...
ELSE
%OUT Not using private stack ...
ENDIF
IF TRANSFER
%OUT Including keyboard transfer code ...
ELSE
%OUT Not including keyboard transfer code ...
ENDIF
public header
header label near
dd -1 ;pointer to next device
dw 8000h ;type device
dw Strat ;strategy entry point
dw Intr ;interrupt entry point
db 'KBUFFER ' ;device name
public req
req dd ? ;store request header vector here
public queue_start,queue_end
queue_start dw BUFSIZE dup (0) ;our expanded keyboard buffer
queue_end equ $ - start ;calculate offset as typeless constant
IF PRIVATESTACK ; v1.6
stack_end db STACKSZ dup (0) ;use our own private data stack
stack_start equ $
oldss dw 0
oldsp dw 0
oldax dw 0
ENDIF
;*****************************************************************************
; Strategy procedure
; Save the pointer to the request header for Intr in the req area.
; Enters with pointer in es:bx
;*****************************************************************************
public Strat
Strat proc far
mov cs:[req].ofs,bx
mov cs:[req].segw,es ; v1.4
ret
Strat endp
;*****************************************************************************
; The main interrupt (driver)
; This is the actual driver. Processes the command contained in the
; request header. (Remember, req points to the request header.)
;*****************************************************************************
public Intr
ASSUME ds:Cseg, es:NOTHING ; v1.4
Intr proc far
IF PRIVATESTACK ;If using private stack, process
mov cs:oldax, ax ; v1.6
cli ; turn ints off
mov ax, ss
mov cs:oldss, ax
mov cs:oldsp, sp
mov sp, offset stack_start
mov ax, cs
mov ss, ax
sti ; turn ints back on
mov ax, cs:oldax
ENDIF
push ds ;save everything in sight
push es
IF USE286
pusha ; v1.5
ELSE
push ax
push bx
push cx
push dx
push di
push si
ENDIF
mov ax,cs
mov ds,ax ;DS=code segment
les bx,req ;point to request hdr v1.4a
mov si,offset cmd_table ;our function table
mov cl,es:[bx].code ;get command
xor ch,ch ;clear msb v1.4
shl cx,1 ;*2 for word addresses
add si,cx ;add to table base
call word ptr [si] ;call our function v1.4a
les bx,cs:req ;get back request hdr vector
mov es:[bx].status,ax ;return status
IF USE286
popa ; v1.5
ELSE
pop si ;clean everything up
pop di
pop dx
pop cx
pop bx
pop ax
ENDIF
pop es
pop ds
IF PRIVATESTACK
mov ax, cs:oldss ; v1.6
cli ; turn ints off
mov ss, ax
mov sp, cs:oldsp
mov ax, cs:oldax
sti ; turn ints on
ENDIF
ret
public cmd_table
cmd_table: ;command routing table
dw Cmd_Init ;0=initialization (we do that)
dw Cmd_None ;1=media check (always SUCCESS)
dw Cmd_None ;2=build BIOS param block (ditto)
dw Cmd_None ;3=IO control input (ditto)
dw Cmd_None ;4=input from device (ditto)
dw Cmd_None ;5=nondest input no-wait (ditto)
dw Cmd_None ;6=input status (ditto)
dw Cmd_None ;7=flush input